Bump to Rector ^2.4.1 and replace deprecated file to getFile() on rector rule#4
Conversation
Review Summary by QodoUpgrade Rector to ^2.4.1 and update deprecated API usage
WalkthroughsDescription• Upgrade Rector dependency from ^2.3 to ^2.4.1 • Replace deprecated $this->file property with getFile() method • Replace Str::of() calls with \str() helper function • Remove unused SafeDeclareStrictTypesRector rule and import • Refactor variable naming for improved code clarity • Remove duplicate PHPUnit DataProvider attribute annotation Diagramflowchart LR
A["Rector ^2.3"] -->|"Upgrade to"| B["Rector ^2.4.1"]
B -->|"Requires API changes"| C["Replace deprecated APIs"]
C -->|"file property"| D["Use getFile() method"]
C -->|"Str::of()"| E["Use str() helper"]
F["Remove unused rules"] -->|"SafeDeclareStrictTypesRector"| G["Clean config"]
File Changes2. rector.dist.php
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Walkthrough升级Rector依赖版本从^2.3至^2.4.1。移除SafeDeclareStrictTypesRector规则。重构多个类中的文件访问方式,将属性直接访问替换为方法调用。调整SortFileFunctionStmtRector中的节点变量处理逻辑。 Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Code Review by Qodo
|
|
@guanguans ready for merge for immediate new release 👍 , I tried only apply related changes as possible ;) |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/Exception/RectorErrorException.php (1)
36-42:⚠️ Potential issue | 🟡 Minor
bindTo方式访问getFile()方法是必要的权衡方案。由于
RectorErrorException继承Error而非AbstractRector,无法直接访问受保护的getFile()方法。使用bindTo($rector, $rector)将闭包临时绑定到 Rector 实例的作用域是解决这个问题的合理方式。虽然
@phpstan-ignore method.nonObject注释表明静态分析器无法理解bindTo的行为,但这不影响运行时的正确性——getFile()是 Rector 核心 API,不会轻易变更。若有其他需要减少代码复杂性,可考虑在构造函数中传入文件路径作为参数,但现有实现是务实的权衡。🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/Exception/RectorErrorException.php` around lines 36 - 42, The use of a bound closure to call the protected getFile() from RectorErrorException is acceptable: keep the (fn (): string => $this->getFile()->getFilePath())->bindTo($rector, $rector)() pattern and retain the `@phpstan-ignore` method.nonObject, but add a short inline comment near that expression explaining why bindTo is used (RectorErrorException extends Error so it cannot access protected getFile() directly) and mention that constructor injection of the file path is an alternative; ensure symbols referenced are RectorErrorException, getFile(), and bindTo in your comment.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@src/Exception/RectorErrorException.php`:
- Around line 36-42: The use of a bound closure to call the protected getFile()
from RectorErrorException is acceptable: keep the (fn (): string =>
$this->getFile()->getFilePath())->bindTo($rector, $rector)() pattern and retain
the `@phpstan-ignore` method.nonObject, but add a short inline comment near that
expression explaining why bindTo is used (RectorErrorException extends Error so
it cannot access protected getFile() directly) and mention that constructor
injection of the file path is an alternative; ensure symbols referenced are
RectorErrorException, getFile(), and bindTo in your comment.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 5e886fcf-82b3-4873-aefc-3e6474b634c1
📒 Files selected for processing (10)
composer.jsonrector.dist.phpsrc/Exception/RectorErrorException.phpsrc/Rector/AbstractRector.phpsrc/Rector/Array_/UpdateRectorCodeSamplesFromFixturesRector.phpsrc/Rector/File/AddNoinspectionDocblockToFileFirstStmtRector.phpsrc/Rector/File/SortFileFunctionStmtRector.phpsrc/Support/ComposerScripts.phptests/Rector/AbstractRectorTestCase.phptests/Support/HelpersTest.php
💤 Files with no reviewable changes (1)
- rector.dist.php
|
@samsonasik Thanks. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4 +/- ##
=========================================
Coverage 99.90% 99.90%
Complexity 308 308
=========================================
Files 20 20
Lines 1011 1011
=========================================
Hits 1010 1010
Misses 1 1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Ref
Summary by CodeRabbit
版本更新说明
维护
代码重构